package com.example.demo.controller;

import com.example.demo.entity.ResultData;
import com.example.demo.entity.Unburden;
import com.example.demo.mapper.UnburdenMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UnburdenController {

    @Autowired
    private UnburdenMapper UnburdenMapper;

    /**
     * 查看留言
     * @param unburden
     * @return
     */
    @RequestMapping(path="/select",method = RequestMethod.GET)
    public Map<String,Object> selectUserInforation ( Unburden unburden){
        Map<String,Object> result = new HashMap<String,Object>();
        result.put("AllUserInfo",UnburdenMapper.selectByUserInforation(unburden));
        System.out.print(result);
        return result;
    }

    /**
     * 新增留言
     * @param unburden
     */
    @RequestMapping(path="/addUserInfo",method = RequestMethod.GET )
    public void addUserInfo (Unburden unburden){
        UnburdenMapper.addUser(unburden);
    }

    /**
     * 网站访问数量
     * @return
     */
    @RequestMapping(path="/visitPeopleNumber",method = RequestMethod.GET)
    public void addVisitPeople(Unburden unburden){
        UnburdenMapper.addVisitPeople(unburden);
    }

    @GetMapping("/api/getTest")
    public ResultData<String> getTest(){
        return ResultData.success("Hello world!");
    }
}
